#ifndef PriorityQueue_h__
#define PriorityQueue_h__

#include <ostream>
#include <vector>
#include <cassert>
//#include "Scheduler.h"

struct TaskInfo;


class PriorityQLow
{
protected:

	std::vector<TaskInfo*>  m_Heap;

	int m_iMaxSize;

	int             m_iSize;


	//given a heap and a node in the heap, this function moves upwards
	//through the heap swapping elements until the heap is ordered
	void ReorderUpwards(std::vector<TaskInfo*>& heap, int nd);


	//given a heap, the heapsize and a node in the heap, this function
	//reorders the elements in a top down fashion by moving down the heap
	//and swapping the current node with the smaller of its two children
	//(provided a child is larger than the current node)
	void ReorderDownwards(std::vector<TaskInfo*>& heap, int nd, int HeapSize);

public:

	PriorityQLow();

	bool empty();

	//to insert an item into the queue it gets added to the end of the heap
	//and then the heap is reordered
	void insert(TaskInfo* item);

	//to get the max item the first element is exchanged with the lowest
	//in the heap and then the heap is reordered from the top down. 
	TaskInfo* pop();

	//so we can take a peek at the first in line
	TaskInfo* peek();

	void Erase(std::vector<TaskInfo*>::iterator itr);
	std::vector<TaskInfo*>::iterator Begin();
	std::vector<TaskInfo*>::iterator End();
};

#endif // PriorityQueue_h__